#------------------------KeyMaker for NeilCipher 0.9.5+------------------------
#------------By Wyn Price, with help from Neil Power and Max Baker------------
#----------------------------------(C) 2015-----------------------------------
#----------------------Licensed for non-commercial reuse----------------------


#New in this version (0.2.0):
    #changed the file it saves to

import time

aa = 150

timeSpace = " "
dateH = time.strftime("%X")
dateD = time.strftime("%x")

def getTime():

    def timehour():
        global dateH
        global timeSpace
        for symbol in dateH:
           if symbol == ":":
               timeSpace = timeSpace + " "
           else:
               timeSpace = timeSpace + symbol
        return timeSpace

    def timeday():
        global dateD
        global timeSpace
        timeSpace = ""
        for symbol in dateD:
           if symbol == "/":
                timeSpace = timeSpace + " "
           else:
                timeSpace = timeSpace + symbol
        return timeSpace

    listtimeint = str.split(timeday())
    listtime = [int(x) for x in listtimeint]
    hour = listtime[0]
    listdayint = str.split(timehour())
    listday = [int(y) for y in listdayint]
    day = listday[1]
    Key1 = (str((day*5)-7) + "O" + str((hour*15)+2))
    file = open("Key.txt",'a')
    with open('Key.txt', 'w') as file:
        file.write(str(Key1))
        file.close()
        print("Done")


def useTime():
    dateHour = input("Please enter the hour(eg 12): ")
    dateDay = input("Please enter the day(eg 31): ")
    hour = int(dateHour)
    day = int(dateDay)
    Key1 = (str((day*5)-7) + "O" + str((hour*15)+2))
    file = open("Key.txt",'a')
    with open('Key.txt', 'w') as file:
        file.write(str(Key1))
        file.close()
    print("Done")

def main():
    while True:
        mod = input("""This program generates the first key for NeilCipher 0.9.5+
Do you want to use the time right now(1), or input a time(2)?
Please enter your choice: """)
        if mod == "1":
            getTime()
        elif mod == "2":
            useTime()
        print("The key has been saved to 'Key.txt'")

print("""------------------------KeyMaker for NeilCipher 0.9.5+------------------------
------------By Wyn Price, with help from Neil Power and Max Baker------------
----------------------------------(C) 2015-----------------------------------
----------------------Licensed for non-commercial reuse----------------------""")

main()

